package com.ruoyi.web.controller.qsng;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.qsng.domain.KUsersInformation;
import com.ruoyi.qsng.service.IKUsersInformationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报名信息Controller
 * 
 * @author kanglou
 * @date 2023-06-07
 */
@RestController
@RequestMapping("/qsng/information")
@Api(tags = "pc--报名信息Controller")
public class KUsersInformationController extends BaseController
{
    @Autowired
    private IKUsersInformationService kUsersInformationService;

    /**
     * 查询报名信息列表
     */
    @PreAuthorize("@ss.hasPermi('qsng:information:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询报名信息列表")
    public TableDataInfo list(KUsersInformation kUsersInformation)
    {
        startPage();
        List<KUsersInformation> list = kUsersInformationService.selectKUsersInformationList(kUsersInformation);
        return getDataTable(list);
    }

    /**
     * 导出报名信息列表
     */
    @PreAuthorize("@ss.hasPermi('qsng:information:export')")
    @Log(title = "报名信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出报名信息列表")
    public void export(HttpServletResponse response, KUsersInformation kUsersInformation)
    {
        List<KUsersInformation> list = kUsersInformationService.selectKUsersInformationList(kUsersInformation);
        ExcelUtil<KUsersInformation> util = new ExcelUtil<KUsersInformation>(KUsersInformation.class);
        util.exportExcel(response, list, "报名信息数据");
    }

    /**
     * 获取报名信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('qsng:information:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取报名信息详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(kUsersInformationService.selectKUsersInformationById(id));
    }

    /**
     * 新增报名信息
     */
    @PreAuthorize("@ss.hasPermi('qsng:information:add')")
    @Log(title = "报名信息", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增报名信息")
    public AjaxResult add(@RequestBody KUsersInformation kUsersInformation)
    {
        return toAjax(kUsersInformationService.insertKUsersInformation(kUsersInformation));
    }

    /**
     * 修改报名信息
     */
    @PreAuthorize("@ss.hasPermi('qsng:information:edit')")
    @Log(title = "报名信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改报名信息")
    public AjaxResult edit(@RequestBody KUsersInformation kUsersInformation)
    {
        return toAjax(kUsersInformationService.updateKUsersInformation(kUsersInformation));
    }

    /**
     * 删除报名信息
     */
    @PreAuthorize("@ss.hasPermi('qsng:information:remove')")
    @Log(title = "报名信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation(value = "删除报名信息")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(kUsersInformationService.deleteKUsersInformationByIds(ids));
    }
}
